import { Resolver, Query, Args, ResolveProperty, Parent } from '@nestjs/graphql';
import { GoodsService } from './goods.service';
import { PageQuery } from '@/common/interfaces/Pagination';
import { Goods, GoodsAttribute } from '@/graphql.schema';
import { GoodsAttributeService } from './goods-attribute.service';
import { Injectable } from '@nestjs/common';

@Resolver('GoodsAttribute')
export class GoodsAttributeReolver {
  constructor(private readonly goodsService: GoodsService,
              private readonly goodsAttributeService: GoodsAttributeService) {}

  @ResolveProperty('goods')
  async getGoods(@Parent() goodsAttribute: GoodsAttribute) {
    return this.goodsService.findById(goodsAttribute.goodsId);
  }
}
